#include "ShellLibrary.h"

void ChangeDirectory(char **args) {
    //char *p;

    printf("primeiro argumento de cd: %s\n", args[1]);
    if(!chdir(args[1])) {
        //p = (char*)get_current_dir_name();
        printf("Now, your current directory is %s\n", (char*)get_current_dir_name());
        //free(p);
    }
    else {
        printf("Error changing the directory: %s\n", strerror(errno));
    }
}

void PrintWorkingDirectory() {
    printf("Your current directory is %s\n", (char*)get_current_dir_name());
}

void CreateDirectory(char **args) {

    if(!mkdir(args[1], S_IRWXU))
        printf("The directory %s was created.\n", args[1]);
    else
        printf("Error creating the directory: %s\n", strerror(errno));
}
